<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.sms.project.*, com.sms.user.*"%>
<%@ page import="net.sf.json.*"%>

<%--
	project/teacher/add-project.jsp
 --%>

<%
	//清除内存
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>

<%
	request.setCharacterEncoding("utf-8");
	String userno = session.getAttribute("userno").toString();
%>

<body>
	<div id="project">
		<p class="tip">
			**项目模式：二级模式是老师管理组长和组员，组长管理组员,三级是指老师管理项目组长，组长管理组员<br>***表示必填项
		</p>
		<form id="add-project" method="post" action="ProjectUploadServlet"
			enctype="multipart/form-data" onSubmit="return check();" target="addProject_iframe">
			<input type="hidden" name="fromID" value="<%=userno%>" />
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td><label for="name">***项目名称：</label>
					</td>
					<td style="text-align:left;"><input name="proName" id="name"
						style="min-width:400px;" />
					</td>
				</tr>
				<tr>
					<td><label for="grade">项目级别：</label>
					</td>
					<td style="text-align:left;"><select name="grade" id="grade" style="min-width:400px;"><option
								value="2">二级模式</option>
							<option value="3">三级模式</option>
					</select>
					</td>
				</tr>
				<tr>
					<td><label for="deadline" style="min-width:400px;">***任务截止时间：</label>
					</td>
					<td style="text-align:left;"><input name="deadline"
						id="deadline" class="easyui-datebox" />
					</td>
					<td id="add-file" style="color:#F00;">继续添加附件</td>
				</tr>
				<tr>
					<td><label for="header">***指定项目组长：</label>
					</td>
					<td style="text-align:left;"><input name="leader" id="header"
						style="min-width:400px;" />
					</td>
				</tr>
				<!--返回json数据-->
				<tr>
					<td><label for="member">添加项目组员：</label>
					</td>
					<td style="text-align:left;"><input name="member" id="member"
						style="min-width:400px;" />
					</td>
				</tr>
				<!--返回json数据-->
				<tr class="addfiles">
					<td><label for="file">添加附件：</label>
					</td>
					<td style="text-align:left;"><input type="file" name="load"
						id="file" style="min-width:400px;" />
					</td>
				</tr>
				<tr>
					<td><label for="desc">***项目描述：</label>
					</td>
					<td><textarea name="proDesc" id="desc"
							style="width:400px; height:200px; overflow:scroll;"></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit"
						id="submit" value="提交" style="margin-top:10px;" />
					</td>
				</tr>
			</table>
		</form>
		
		<iframe name="addProject_iframe" style="display:none;">
		</iframe>
	</div>
	<script type="text/javascript">
		$("#header").combobox({
			multiple : false,
			url : 'GetStudentServlet',/*返回json数据格式的链接*/
			valueField : 'sno',
			textField : 'sname',
			editable : false,
			required : true,
			missingMessage : "此项为必填项"
		})

		$("#member").combobox({
			multiple : true,
			url : 'GetStudentServlet',/*返回json数据格式的链接*/
			valueField : 'sno',
			textField : 'sname',
			editable : false,
			//required : true,
			//missingMessage : "此项为必填项"
		})

		$("#add-file").click(function() {
			var clonefile = $(".addfiles").first().clone();
			if ($(".addfiles").length <= 4) {
				$(".addfiles").last().after(clonefile);
			} else {
				alert('亲，一次性最多只能添加5个附件哦');
			}
		})
		
		function callback(msg)   
		{   
   		 	//alert(msg);
		 	if(msg=='ok'){                              
		 		alert('添加成功');
		 		var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'project/teacher/project.jsp',
									 }
									});  /*更新面板*/
		 		$('#dd').dialog('close');
		 	}
		 	else{
			 	alert('添加不成功!');
		 	}
		 }


		$('#deadline').datebox(
				{
					okText : '确定',
					editable : false,
					required : true,
					missingMessage : "此项为必填项",
					formatter : function(date) {
						return date.getFullYear() + '-' + (date.getMonth() + 1)
								+ '-' + date.getDate();

					}
				})
		$('#name,#desc').validatebox({
			required : true,
			missingMessage : "此项为必填项"
		})
		function check() {
			var name = $("#name").val();
			var deadline = $('#deadline').datebox('getValue');
			var header = $("#header").combobox('getValue');
			var desc = $('#desc').val();
			//var member = $("#member").combobox('getValue');
			if (name && deadline && desc && header) {
				return true;
			} else {
				alert('请补充完整信息');
				return false;
			}
		}
	</script>
</body>

